Repeat ping requests & fix connection keep-alive#416
Repeat ping requests & fix connection keep-alive#416dharjeezy wants to merge 16 commits intoparitytech:masterfrom
Conversation
dmitry-markin
left a comment
There was a problem hiding this comment.
Hey, this is going in the right direction, but there should be a way to simplify the implementation by not introducing separate async tasks for inbound/outbound substreams and not adding command channels. It should be possible to implement polling of inbound substreams by putting them into FuturesUnordered or, may be, tokio_stream::StreamMap. The latter should be quite easy as there is maximum one inbound substream allowed from any remote peer as per ping spec: https://github.com/libp2p/specs/blob/master/ping/ping.md
|
@dmitry-markin can you check my current implementation |
There was a problem hiding this comment.
Hey hey, nice use of SplitStream/SplitSink! I think what is missing is a cleaner separation between inbound and outbound substreams. On inbound substreams we should only respond to incoming pings, and on outbound send pings ourself. It would be better than relying on the presence of the time in the map, which can get screwed when we both send pings to a peer and receive pings from it.
i have done this now @dmitry-markin |
|
Out of scope for this PR but I noticed that |
There was a problem hiding this comment.
FWIW, I ran the following tests, using a litep2p listener and webrtc transport:
| Dialer | Listener -> Dialer Pings | Dialer -> Listener Pings |
|---|---|---|
| libp2p | ❌ | ✅ |
| "minimal smoldot env" | ✅ | ✅ |
The failing outbound pings with libp2p is an unrelated issue (#494).
src/protocol/libp2p/ping/mod.rs
Outdated
|
|
||
| /// Log target for the file. | ||
| const LOG_TARGET: &str = "litep2p::ipfs::ping"; | ||
| const PING_TIMEOUT: Duration = Duration::from_secs(10); |
There was a problem hiding this comment.
| const PING_TIMEOUT: Duration = Duration::from_secs(10); |
Since it is unused. However, we probably want to have a timeout for receiving pongs. Arguably out of scope for this PR though.
|
@lexnv @haikoschol @dmitry-markin please help review |
LGTM, but my approval doesn't count towards mergeability. |
…mi/repeat-request-periodically
|
Sorry for huge delay with reviewing. I have finally looked into the PR and tried to make it properly register protocols with appropriate keep-alive settings (dharjeezy-ping-keep-alive...dm-ping-keep-alive), but it turned out to be more tricky than I thought. The connection keep-alive mechanism relied on the fact that ping substreams were periodically opened, because the actual connection tear down happened only when somebody tried to open a new substream. With reused substreams it doesn't work anymore. I am going to look further into this. Meanwhile, please don't push new changes to the PR. Thanks for all the work done so far! |
FWIW, after testing with a full smoldot light client (as opposed to our minimal test env), I am pretty sure that merging this would increase stability of connections from smoldot to full nodes. I've included the changes in this PR in my branch that I've used for testing. |
Yes, smoldot needs a permanent ping substream (as per libp2p ping spec), or will disconnect litep2p on a second ping attempt trying to write to substream that was reset. This is why this issue is of a higher priority now. |
This PR:
ProtocolCommandchannel.Closes #415